class Furniture:
    """家具类"""

    def __init__(self, name, area):
        # 家具的名称
        self.name = name
        # 家具的面积
        self.area = area

    def __str__(self):
        return f'{self.name}面积{self.area}㎡'


class House:
    """房屋类"""

    def __init__(self, address, area):
        # 房屋的地址
        self.address = address
        # 房屋的总面积
        self.total_area = area
        # 房屋的剩余面积
        self.free_area = area
        # 房屋内摆放的家具
        self.furniture = []

    def add_furniture(self, item: Furniture):
        """给房子添加家具"""
        if not isinstance(item, Furniture):
            return

        if item.area <= self.free_area:
            self.free_area -= item.area
            self.furniture.append(item.name)
        else:
            print(f'剩余面积不足，无法容纳{item.name}')

    def __str__(self):
        return f'房子位于{self.address}，总面积{self.total_area}㎡，' \
               f'剩余面积{self.free_area}㎡，家具有{"、".join(self.furniture)}'


if __name__ == '__main__':
    bed = Furniture('双人床', 10)
    sofa = Furniture('沙发', 20)
    washer = Furniture('洗衣机', 10)
    ice_box = Furniture('冰箱', 40)

    house = House('北京', 60)
    print(house)

    house.add_furniture(bed)
    print(house)

    house.add_furniture(sofa)
    print(house)

    house.add_furniture(washer)
    print(house)

    house.add_furniture(ice_box)
    print(house)
